<?php
namespace app\organization\controller\say;

use app\common\controller\Frontend;
use app\common\model\banxi\say\SayTeachSentence as SayTeachSentenceModel;
use think\db\exception\DbException;

class TeachSentence extends Frontend
{
    protected array $noNeedLogin = [];
    protected array $noNeedPermission = ["*"];

    public function initialize(): void
    {
        parent::initialize();
        $this->model = new SayTeachSentenceModel();
    }


    /**
     * 分页查询
     * @return void
     * @throws DbException
     */
    public function listPage(): void
    {
        $param = $this->request->param(['index', 'limit', 'orderBy', "query"]);
        //查询条件解析
        $where = get_query($param);
        //获取分页数据
        $pageParams = get_page_params($param);
        $list = $this->model->getListPage($where, $pageParams['page'], $pageParams['limit']);
        $this->ok('操作成功', result_row($list));
    }

    /**
     * 分页-学员开通课程查询
     * @return void
     * @throws DbException
     */
    public function listStudentOpenPage(): void
    {
        $param = $this->request->param(['index', 'limit', 'orderBy', "query", "isPractice", "studentId"]);
        // die;
        //查询条件解析
        $where = get_query($param);
        //获取分页数据
        $pageParams = get_page_params($param);
        $list = $this->model->getListStudentOpenPage((bool)$param['isPractice'], $param['studentId'], $where, $pageParams['page'], $pageParams['limit']);
        $this->ok('操作成功', result_row($list));
    }

    /**
     * 分页-学员未开通课程查询
     * @return void
     * @throws DbException
     */
    public function listStudentPage(): void
    {
        $param = $this->request->param(['index', 'limit', 'orderBy', "query", "studentId"]);
        //查询条件解析
        $where = get_query($param);
        //获取分页数据
        $pageParams = get_page_params($param);
        $list = $this->model->getListStudentPage( $param['studentId'], $where, $pageParams['page'], $pageParams['limit']);
        $this->ok('操作成功', result_row($list));
    }

}
